package com.ruoyi.web.controller.fantasy;

import java.util.List;

import com.huanzhidadi.fantasy.bean.domain.FantasyMapShop;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.fantasy.service.IFantasyMapShopService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 地图商店关系 信息操作处理
 * 
 * @author wanghui
 * @date 2020-01-29
 */
@Controller
@RequestMapping("/fantasy/fantasyMapShop")
public class FantasyMapShopController extends BaseController
{
    private String prefix = "fantasy/fantasyMapShop";
	
	@Autowired
	private IFantasyMapShopService fantasyMapShopService;
	
	@RequiresPermissions("fantasy:fantasyMapShop:view")
	@GetMapping()
	public String fantasyMapShop()
	{
	    return prefix + "/fantasyMapShop";
	}
	
	/**
	 * 查询地图商店关系列表
	 */
	@RequiresPermissions("fantasy:fantasyMapShop:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(FantasyMapShop fantasyMapShop)
	{
		startPage();
        List<FantasyMapShop> list = fantasyMapShopService.selectFantasyMapShopList(fantasyMapShop);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出地图商店关系列表
	 */
	@RequiresPermissions("fantasy:fantasyMapShop:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FantasyMapShop fantasyMapShop)
    {
    	List<FantasyMapShop> list = fantasyMapShopService.selectFantasyMapShopList(fantasyMapShop);
        ExcelUtil<FantasyMapShop> util = new ExcelUtil<FantasyMapShop>(FantasyMapShop.class);
        return util.exportExcel(list, "fantasyMapShop");
    }
	
	/**
	 * 新增地图商店关系
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存地图商店关系
	 */
	@RequiresPermissions("fantasy:fantasyMapShop:add")
	@Log(title = "地图商店关系", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(FantasyMapShop fantasyMapShop)
	{		
		return toAjax(fantasyMapShopService.insertFantasyMapShop(fantasyMapShop));
	}

	/**
	 * 修改地图商店关系
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		FantasyMapShop fantasyMapShop = fantasyMapShopService.selectFantasyMapShopById(id);
		mmap.put("fantasyMapShop", fantasyMapShop);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存地图商店关系
	 */
	@RequiresPermissions("fantasy:fantasyMapShop:edit")
	@Log(title = "地图商店关系", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(FantasyMapShop fantasyMapShop)
	{		
		return toAjax(fantasyMapShopService.updateFantasyMapShop(fantasyMapShop));
	}
	
	/**
	 * 删除地图商店关系
	 */
	@RequiresPermissions("fantasy:fantasyMapShop:remove")
	@Log(title = "地图商店关系", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(fantasyMapShopService.deleteFantasyMapShopByIds(ids));
	}
	
}
